{extend name='common/container'}
{block name="content"}
<div style="margin:0 15px 15px 15px;">
<el-card shadow="never" style="min-height:650px;">
<div v-if="search_visible" id="search" class="search">
	<el-form ref="form" size="small" :model="searchData" inline>
		<el-form-item label="编号">
			<el-input id="resourcse_id" v-model="searchData.resourcse_id"  style="width:150px;" placeholder="请输入编号"></el-input>
		</el-form-item>
		<el-form-item label="添加时间">
			<el-date-picker value-format="yyyy-MM-dd HH:mm:ss" type="daterange" v-model="searchData.add_time" clearable range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
		</el-form-item>
		<el-form-item label="资源类型">
			<el-select style="width:150px" v-model="searchData.status" filterable clearable placeholder="请选择">
				<el-option key="0" label="新" value="1"></el-option>
				<el-option key="1" label="旧" value="2"></el-option>
			</el-select>
		</el-form-item>
		<el-form-item label="跟单状态">
			<el-select style="width:150px" v-model="searchData.save_display" filterable clearable placeholder="请选择">
				<el-option key="0" label="未跟单" value="0"></el-option>
				<el-option key="1" label="已跟单" value="1"></el-option>
			</el-select>
		</el-form-item>
		<el-form-item label="联系人">
			<el-input id="name" v-model="searchData.name"  style="width:150px;" placeholder="请输入联系人"></el-input>
		</el-form-item>
		<el-form-item label="手机号码">
			<el-input id="mobile" v-model="searchData.mobile"  style="width:150px;" placeholder="请输入手机号码"></el-input>
		</el-form-item>
		<el-form-item label="资源描述">
			<el-input id="info" v-model="searchData.info"  style="width:150px;" placeholder="请输入资源描述"></el-input>
		</el-form-item>
		<el-form-item label="租金转让">
			<el-input id="sell" v-model="searchData.sell"  style="width:150px;" placeholder="请输入租金转让"></el-input>
		</el-form-item>
		<el-form-item label="区域">
			<el-input id="regoin" v-model="searchData.regoin"  style="width:150px;" placeholder="请输入区域"></el-input>
		</el-form-item>
		<el-form-item label="经营类型">
			<el-select style="width:150px" v-model="searchData.type" filterable clearable placeholder="请选择">
				<el-option key="0" label="餐饮美食" value="餐饮美食"></el-option>
				<el-option key="1" label="美容美发" value="美容美发"></el-option>
				<el-option key="2" label="服饰鞋包" value="服饰鞋包"></el-option>
				<el-option key="3" label="休闲娱乐" value="休闲娱乐"></el-option>
				<el-option key="4" label="百货超市" value="百货超市"></el-option>
				<el-option key="5" label="生活服务" value="生活服务"></el-option>
				<el-option key="6" label="电器通讯" value="电器通讯"></el-option>
				<el-option key="7" label="汽修美容" value="汽修美容"></el-option>
				<el-option key="8" label="医疗器械" value="医疗器械"></el-option>
				<el-option key="9" label="家居建材" value="家居建材"></el-option>
				<el-option key="10" label="教育培训" value="教育培训"></el-option>
				<el-option key="11" label="酒店宾馆" value="酒店宾馆"></el-option>
				<el-option key="12" label="其他" value="其他"></el-option>
			</el-select>
		</el-form-item>
		<el-form-item label="跟单方式">
			<el-select style="width:150px" v-model="searchData.documentary_mothod" filterable clearable placeholder="请选择">
				<el-option key="0" label="电话沟通" value="1"></el-option>
				<el-option key="1" label="微信交流" value="2"></el-option>
				<el-option key="2" label="QQ/旺旺" value="3"></el-option>
				<el-option key="3" label="电子邮箱" value="4"></el-option>
				<el-option key="4" label="上门拜访" value="5"></el-option>
			</el-select>
		</el-form-item>
		<el-form-item label="客户类型">
			<el-select style="width:150px" v-model="searchData.connection_type" filterable clearable placeholder="请选择">
				<el-option key="0" label="保护客户" value="1"></el-option>
				<el-option key="1" label="收藏客户" value="2"></el-option>
			</el-select>
		</el-form-item>
		<el-form-item label="进展">
			<el-select style="width:150px" v-model="searchData.evolve" filterable clearable placeholder="请选择">
				<el-option key="0" label="待访问客户" value="1"></el-option>
				<el-option key="1" label="考虑客户" value="2"></el-option>
				<el-option key="2" label="无效客户" value="3"></el-option>
			</el-select>
		</el-form-item>
		<el-form-item label="微信号">
			<el-input id="weixin" v-model="searchData.weixin"  style="width:150px;" placeholder="请输入微信号"></el-input>
		</el-form-item>
		<search-tool :search_data.sync="searchData" @refesh_list="index"></search-tool>
	</el-form>
</div>
<div class="btn-group" style="margin-top:10px;margin-bottom:10px;">
	<div>
		<el-button v-for="item in button_group" :key="item.access" v-if="checkPermission(item.access,'{:implode(',',session('admin.access'))}','{:session('admin.role_id')}',[1])" :disabled="$data[item.disabled]" :type="item.color" size="mini" :icon="item.icon" @click="fn(item.clickname)">
			<span v-if="item.batch" v-text="$data['batchUpdateStatus']?'批量保存':'批量编辑'"></span>
			<span v-else v-text="item.name"></span>
		</el-button>
	</div>
	<div><table-tool :search_visible.sync="search_visible"   @refesh_list="index"></table-tool></div>
</div>
<!--
<div><h3 style="color:#f00;">提示：以下资源会自动刷新显示，不用手动刷新</h3></div>
-->
<el-table :row-class-name="rowClass" @selection-change="selection"  @row-click="handleRowClick"  row-key="resourcse_id"  :header-cell-style="{ background: '#eef1f6', color: '#606266' }" @sort-change='sortChange' v-loading="loading"  ref="multipleTable" border class="eltable" :data="list"  style="width: 100%">
	<el-table-column align="center" type="selection" width="42"></el-table-column>
	<el-table-column align="center" type = '' property="resourcse_id"  label="编号"  width="70">
	</el-table-column>
	<el-table-column align="left"  property="add_time"  label="添加时间" show-overflow-tooltip width="150">
		<template slot-scope="scope">
			{{parseTime(scope.row.add_time)}}
		</template>
	</el-table-column>
	<!--leewp新增-->
	<el-table-column align="left"  property="top_time"  label="顶贴时间" show-overflow-tooltip width="150">
		<template slot-scope="scope">
			{{parseTime(scope.row.top_time)}}
		</template>
	</el-table-column>
	<!--
	<el-table-column align="left"  property="top_day"  label="时间差" show-overflow-tooltip width="150">
		<template slot-scope="scope">
			顶{{scope.row.top_day}}天
		</template>
	</el-table-column>
	-->
	<el-table-column align="center"  property="status"  label="资源类型" show-overflow-tooltip width="">
		<template slot-scope="scope">
			<el-tag type="danger" v-if="scope.row.status == '1'" size="mini" effect="dark">新</el-tag>
			<el-tag type="info" v-if="scope.row.status == '2'" size="mini" effect="dark">旧</el-tag>
			<el-tag type="danger" v-if="scope.row.status != '1' && scope.row.status != '2'" size="mini" effect="dark">{{scope.row.status}}</el-tag>
		</template>
	</el-table-column>
	<el-table-column align="center"  property="save_display"  label="跟单状态" show-overflow-tooltip width="">
		<template slot-scope="scope">
			<el-tag type="primary" v-if="scope.row.save_display == '0'" size="mini" effect="dark">未跟单</el-tag>
			<el-tag type="danger" v-if="scope.row.save_display == '1'" size="mini" effect="dark">已跟单</el-tag>
		</template>
	</el-table-column>
	<el-table-column align="left"  property="name"  label="联系人" show-overflow-tooltip width="">
	</el-table-column>
	<el-table-column align="left"  property="mobile"  label="手机号码" show-overflow-tooltip width="">
	</el-table-column>
	<el-table-column align="right"  property="info"  label="资源描述" show-overflow-tooltip width="220">
	</el-table-column>
	<el-table-column align="right"  property="sell"  label="租金转让" show-overflow-tooltip width="220">
	</el-table-column>
	<el-table-column align="center"  property="regoin"  label="区域" show-overflow-tooltip width="">
	</el-table-column>
	<el-table-column align="center"  property="type"  label="经营类型" show-overflow-tooltip width="">
		<template slot-scope="scope">
			<span v-if="scope.row.type == '餐饮美食'" >餐饮美食</span>
			<span v-if="scope.row.type == '美容美发'" >美容美发</span>
			<span v-if="scope.row.type == '服饰鞋包'" >服饰鞋包</span>
			<span v-if="scope.row.type == '休闲娱乐'" >休闲娱乐</span>
			<span v-if="scope.row.type == '百货超市'" >百货超市</span>
			<span v-if="scope.row.type == '生活服务'" >生活服务</span>
			<span v-if="scope.row.type == '电器通讯'" >电器通讯</span>
			<span v-if="scope.row.type == '汽修美容'" >汽修美容</span>
			<span v-if="scope.row.type == '医疗器械'" >医疗器械</span>
			<span v-if="scope.row.type == '家居建材'" >家居建材</span>
			<span v-if="scope.row.type == '教育培训'" >教育培训</span>
			<span v-if="scope.row.type == '酒店宾馆'" >酒店宾馆</span>
			<span v-if="scope.row.type == '其他'" >其他</span>
		</template>
	</el-table-column>
	<el-table-column align="center"  property="click"  label="点击" show-overflow-tooltip width="">
	</el-table-column>
	<el-table-column align="right"  property="doucmentary_num"  label="跟单次数" show-overflow-tooltip width="">
	</el-table-column>
	<el-table-column align="right"  property="documentary_info"  label="跟单详情" show-overflow-tooltip width="">
	</el-table-column>
	<el-table-column align="center"  property="documentary_mothod"  label="跟单方式" show-overflow-tooltip width="">
		<template slot-scope="scope">
			<el-tag type="primary" v-if="scope.row.documentary_mothod == '1'" size="mini" effect="dark">电话沟通</el-tag>
			<el-tag type="primary" v-if="scope.row.documentary_mothod == '2'" size="mini" effect="dark">微信交流</el-tag>
			<el-tag type="primary" v-if="scope.row.documentary_mothod == '3'" size="mini" effect="dark">QQ/旺旺</el-tag>
			<el-tag type="primary" v-if="scope.row.documentary_mothod == '4'" size="mini" effect="dark">电子邮箱</el-tag>
			<el-tag type="primary" v-if="scope.row.documentary_mothod == '5'" size="mini" effect="dark">上门拜访</el-tag>
		</template>
	</el-table-column>
	<el-table-column align="right"  property="evolve"  label="进展" show-overflow-tooltip width="">
		<template slot-scope="scope">
			<el-tag type="primary" v-if="scope.row.evolve == '1'" size="mini" effect="dark">待访问客户</el-tag>
			<el-tag type="success" v-if="scope.row.evolve == '2'" size="mini" effect="dark">考虑客户</el-tag>
			<el-tag type="danger" v-if="scope.row.evolve == '3'" size="mini" effect="dark">无效客户</el-tag>
		</template>
	</el-table-column>
	<el-table-column :fixed="ismobile()?false:'right'" label="操作" align="center" width="370">
		<template slot-scope="scope">
			<div v-if="scope.row.resourcse_id">
				<el-button v-if="checkPermission('/admin/Resource/detail.html','{:implode(",",session("admin.access"))}','{:session("admin.role_id")}',[1])" size="mini" icon="el-icon-view" type="info" @click="detail(scope.row)" >查看跟单</el-button>
				<el-button v-if="checkPermission('/admin/Resource/documentaryUrl.html','{:implode(",",session("admin.access"))}','{:session("admin.role_id")}',[1])" size="mini" icon="el-icon-plus" type="warning" @click="documentaryUrl(scope.row)" >跟单记录</el-button>
				<el-button v-if="scope.row.mobile_repeat_bh != null && scope.row.mobile_repeat_bh != '' && checkPermission('/admin/Resource/mobileRepeat.html','{:implode(",",session("admin.access"))}','{:session("admin.role_id")}',[1])" size="mini" icon="el-icon-zoom-in" type="danger" @click="mobileRepeat(scope.row)" >重复手机号</el-button>
			</div>
		</template>
	</el-table-column>
</el-table>
<Page :total="page_data.total" :page.sync="page_data.page" :limit.sync="page_data.limit" @pagination="index" />
</el-card>

<!--添加-->
<Add :show.sync="dialog.addDialogStatus" size="small" @refesh_list="index"></Add>
<!--修改-->
<Update :info="updateInfo" :show.sync="dialog.updateDialogStatus" size="small" @refesh_list="index"></Update>
<!--查看跟单-->
<Detail :info="detailInfo" :show.sync="dialog.detailDialogStatus" size="small" @refesh_list="index"></Detail>
<!--跟单记录-->
<DocumentaryUrl :info="documentaryUrlInfo" :show.sync="dialog.documentaryUrlDialogStatus" size="small"></DocumentaryUrl>
<!--取消保护(公共资源)-->
<DialogUrl :info="dialogUrlInfo" :show.sync="dialog.dialogUrlDialogStatus" size="small"></DialogUrl>
<!--重复手机号-->
<MobileRepeat :info="mobileRepeatInfo" :show.sync="dialog.mobileRepeatDialogStatus" size="small"></MobileRepeat>

</div>

{/block}
{block name="script"}
<script src="__PUBLIC__/assets/js/app.js"></script>
<script src="__PUBLIC__/components/admin/resource/add.js?v=<?php echo rand(1000,9999)?>"></script>
<script src="__PUBLIC__/components/admin/resource/update.js?v=<?php echo rand(1000,9999)?>"></script>
<script src="__PUBLIC__/components/admin/resource/detail.js?v=<?php echo rand(1000,9999)?>"></script>
<script src="__PUBLIC__/components/admin/resource/documentaryUrl.js?v=<?php echo rand(1000,9999)?>"></script>
<script src="__PUBLIC__/components/admin/resource/dialogUrl.js?v=<?php echo rand(1000,9999)?>"></script>
<script src="__PUBLIC__/components/admin/resource/mobileRepeat.js?v=<?php echo rand(1000,9999)?>"></script>
<script>
new Vue({
	el: '#app',
	components:{
	},
	data: function() {
		return {
			dialog: {
				addDialogStatus : false,
				updateDialogStatus : false,
				detailDialogStatus : false,
				documentaryUrlDialogStatus : false,
				dialogUrlDialogStatus : false,
				mobileRepeatDialogStatus : false,
			},
			searchData:{},
			button_group:[
				{name:'添加',color:'success',access:'/admin/Resource/add.html',icon:'el-icon-plus',disabled:'',clickname:'add'},
				{name:'修改',color:'primary',access:'/admin/Resource/update.html',icon:'el-icon-edit',disabled:'single',clickname:'update'},
				{name:'顶贴',color:'primary',access:'/admin/Resource/update_top.html',icon:'',disabled:'single',clickname:'update_top'}, //leewp新增
				{name:'删除',color:'danger',access:'/admin/Resource/delete.html',icon:'el-icon-delete',disabled:'multiple',clickname:'del'},
				{name:'查看跟单',color:'info',access:'/admin/Resource/detail.html',icon:'el-icon-view',disabled:'single',clickname:'detail'},
				{name:'跟单记录',color:'warning',access:'/admin/Resource/documentaryUrl.html',icon:'el-icon-plus',disabled:'single',clickname:'documentaryUrl'},
				{name:'保护客户',color:'danger',access:'/admin/Resource/protect.html',icon:'',disabled:'',clickname:'protect'},
				{name:'取消保护(公共资源)',color:'warning',access:'/admin/Resource/dialogUrl.html',icon:'el-icon-plus',disabled:'',clickname:'dialogUrl'},
			],
			loading: false,
			page_data: {
				limit: 20,
				page: 1,
				total:20,
			},
			order:'',
			sort:'',
			ids: [],
			single:true,
			multiple:true,
			search_visible:true,
			list: [],
			updateInfo:{},
			detailInfo:{},
			documentaryUrlInfo:{},
			dialogUrlInfo:{},
			mobileRepeatInfo:{},
		}
	},
	methods:{
		index(){
			let param = {limit:this.page_data.limit,page:this.page_data.page,order:this.order,sort:this.sort}
			Object.assign(param, this.searchData,this.urlobj)
			//this.loading = true    //Lee注释
			console.log("=========>>>", param)
			axios.post(base_url + '/Resource/index',param).then(res => {
				if(res.data.status == 200){
					this.list = res.data.data.data
				// 	新消息提醒放在了common/container
				// 	const listData = res.data.data.data;
				// 	const listLength = listData.filter(item=> item.save_display == 0);
				// 	if(listLength.length>0){
				// 	    this.$message.error('有待处理的订单，请尽快处理！');
				// 	    this.playNewOrderSound();
				// 	}
					this.page_data.total = res.data.data.total
					this.loading = false
				}else{
					this.$message.error(res.data.msg);
				}
			})
		},
		updateExt(row,field){
			if(row.resourcse_id){
				axios.post(base_url + '/Resource/updateExt',{resourcse_id:row.resourcse_id,[field]:row[field]}).then(res => {
					if(res.data.status == 200){
						this.$message({message: res.data.msg, type: 'success'})
					}else{
						this.$message.error(res.data.msg)
					}
				})
			}
		},
		add(){
			this.dialog.addDialogStatus = true
		},
		update(row){
			let id = row.resourcse_id ? row.resourcse_id : this.ids.join(',')
			axios.post(base_url + '/Resource/getUpdateInfo',{resourcse_id:id}).then(res => {
				if(res.data.status == 200){
					this.dialog.updateDialogStatus = true
					this.updateInfo = res.data.data
				}else{
					this.$message.error(res.data.msg)
				}
			})
		},
		del(row){
			this.$confirm('确定操作吗?', '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(() => {
				let ids = row.resourcse_id ? row.resourcse_id : this.ids.join(',')
				axios.post(base_url + '/Resource/delete',{resourcse_id:ids}).then(res => {
					if(res.data.status == 200){
						this.$message({message: res.data.msg, type: 'success'})
						this.index()
					}else{
						this.$message.error(res.data.msg)
					}
				})
			}).catch(() => {})
		},
		//leewp新增
		update_top(row){
			this.$confirm('确定操作顶贴吗?', '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(() => {
				let id = row.resourcse_id ? row.resourcse_id : this.ids.join(',')
				axios.post(base_url + '/Resource/update_top',{resourcse_id:id}).then(res => {
					if(res.data.status == 200){
						this.$message({message: res.data.msg, type: 'success'})
						this.index()
					}else{
						this.$message.error(res.data.msg)
					}
				})
			}).catch(() => {})
		},
		detail(row){
			this.dialog.detailDialogStatus = true
			this.detailInfo = {resourcse_id:row.resourcse_id ? row.resourcse_id : this.ids.join(',')}
		},
		documentaryUrl(row){
			let ids = row.resourcse_id ? row.resourcse_id : this.ids.join(',')
			let data = {}
			this.list.forEach((item,i) => {
				if(item.resourcse_id == ids){
					data = this.list[i]
				}
			})
			this.documentaryUrlInfo = data
			this.dialog.documentaryUrlDialogStatus = true
		},
		protect(){
			let param = {limit:this.page_data.limit,page:this.page_data.page,order:this.order,sort:this.sort}
			Object.assign(param, this.searchData,this.urlobj)
			this.loading = true
			axios.post(base_url + '/Resource/protect',param).then(res => {
				if(res.data.status == 200){
					this.list = res.data.data.data
					this.page_data.total = res.data.data.total
					this.loading = false
				}else{
					this.$message.error(res.data.msg);
				}
			})
		},
		dialogUrl(row){
			let ids = row.resourcse_id ? row.resourcse_id : this.ids.join(',')
			let data = {}
			this.list.forEach((item,i) => {
				if(item.resourcse_id == ids){
					data = this.list[i]
				}
			})
			this.dialogUrlInfo = data
			this.dialog.dialogUrlDialogStatus = true
		},
		mobileRepeat(row){
			let ids = row.resourcse_id ? row.resourcse_id : this.ids.join(',')
			let data = {}
			this.list.forEach((item,i) => {
				if(item.resourcse_id == ids){
					data = this.list[i]
				}
			})
			this.mobileRepeatInfo = data
			this.dialog.mobileRepeatDialogStatus = true
		},
		selection(selection) {
			this.ids = selection.map(item => item.resourcse_id)
			this.single = selection.length != 1
			this.multiple = !selection.length
		},
		handleRowClick(row, rowIndex,event){
			if(event.target.className !== 'el-input__inner'){
				this.$refs.multipleTable.toggleRowSelection(row)
			}
		},
		rowClass ({ row, rowIndex }) {
			for(let i=0;i<this.ids.length;i++) {
				if (row.resourcse_id === this.ids[i]) {
					return 'rowLight'
				}
			}
		},
		sortChange(val){
			if(val.order == 'descending'){
				this.order= 'desc'
			}
			if(val.order == 'ascending'){
				this.order= 'asc'
			}
			this.sort = val.prop
			this.index()
		},
		fn(method){
			this[method](this.ids)
		},
// 		playNewOrderSound() {
// 		    // 新订单音频文件
//     		const audio = new Audio('https://hxadmin.qiaoyuly.com/audio/newreport.wav');
//     		audio.play();
//     		if(audio.play){
//     		    audio.stop();
//     		}                               
// 		},
	},
	mounted(){
		this.index();
		
// 		setInterval(() => {
// 			this.index();
// 		}, 6000);  //Lee新增
		
	},
})
</script>
{/block}
